# coding:utf-8

import json
import pickle
# JSONEncoder


# json.loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
#         parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
#
# json.load(fp, *, cls=None, object_hook=None, parse_float=None,
#         parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
#
# json.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
#         allow_nan=True, cls=None, indent=None, separators=None,
#         default=None, sort_keys=False, **kw)

# json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,
#         allow_nan=True, cls=None, indent=None, separators=None,
#         default=None, sort_keys=False, **kw)

# json.loads(s: str) --> dict  # 用于将str类型的数据转成dict
# json.dumps(d: dict) --> str
# json.dump(d: dict, f: filePath) --> None  # 用于将dict类型的数据转成str，并写入到json文件中
# json.load(d: dict, f: filePath)  # 用于将dict类型的数据转成str，并写入到json文件中

d = {'name': 'tom', 'age': 20, 'interest': ['music', 'movie']}
s = json.dumps(d)
print(type(d), type(s), s)
# <class 'dict'> <class 'str'> {"name": "tom", "age": 20, "interest": ["music", "movie"]}

dd = json.loads(s)
print(type(dd), dd)
# <class 'dict'> {'name': 'tom', 'age': 20, 'interest': ['music', 'movie']}

print()

json.dump(d, open('./000-test.json', 'w'))
# print(type(sp), sp)
print('end')
